<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>POSIX terminal interface</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/POSIX_terminal_interface"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.pygments.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-POSIX_terminal_interface rootpage-POSIX_terminal_interface skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">POSIX terminal interface</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<p>The <b>POSIX terminal interface</b> is the generalized abstraction, comprising both an <a href="Application_programming_interface" class="mw-redirect" title="Application programming interface">application programming interface</a> for programs, and a set of behavioural expectations for users of a <a href="Terminal_(telecommunication)" title="Terminal (telecommunication)">terminal</a>, as defined by the <a href="POSIX" title="POSIX">POSIX</a> standard and the <a href="Single_Unix_Specification" class="mw-redirect" title="Single Unix Specification">Single Unix Specification</a>. It is a historical development from the terminal interfaces of BSD version 4 and <a href="Seventh_Edition_Unix" class="mw-redirect" title="Seventh Edition Unix">Seventh Edition Unix</a>.
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="General_underlying_concepts">General underlying concepts</h2></div>
<div class="mw-heading mw-heading3"><h3 id="Hardware">Hardware</h3></div>
<p>A multiplicity of I/O devices are regarded as "terminals" in Unix systems.<sup id="cite_ref-FOOTNOTEChristian198811_1-0" class="reference"><a href="#cite_note-FOOTNOTEChristian198811-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-FOOTNOTEBourne19836_2-0" class="reference"><a href="#cite_note-FOOTNOTEBourne19836-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> These include:
</p>
<ul><li>serial devices connected by a <a href="Serial_port" title="Serial port">serial port</a> such as <a href="Printer_(computing)" title="Printer (computing)">printers</a>/<a href="Teleprinter" title="Teleprinter">teleprinters</a>, <a href="Teletypewriter" class="mw-redirect" title="Teletypewriter">teletypewriters</a>, <a href="Modem" title="Modem">modems</a> supporting <i>remote</i> <a href="Terminal_(telecommunication)" title="Terminal (telecommunication)">terminals</a> via <a href="Dial-up_access" class="mw-redirect" title="Dial-up access">dial-up access</a>, and directly connected <i>local</i> terminals<sup id="cite_ref-FOOTNOTEChristian198811_1-1" class="reference"><a href="#cite_note-FOOTNOTEChristian198811-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-FOOTNOTECoffin1991820_3-0" class="reference"><a href="#cite_note-FOOTNOTECoffin1991820-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-FOOTNOTECoffin199123&ndash;24_4-0" class="reference"><a href="#cite_note-FOOTNOTECoffin199123&ndash;24-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989259_5-0" class="reference"><a href="#cite_note-FOOTNOTELefflerMcKusickKarelsQuarterman1989259-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Display_adapter" class="mw-redirect" title="Display adapter">display adapter</a> and <a href="Keyboard_(computing)" class="mw-redirect" title="Keyboard (computing)">keyboard</a> hardware directly incorporated into the system unit, taken together to form a local "console", which may be presented to users and to programs as a single CRT terminal or as multiple <a href="Virtual_terminal" title="Virtual terminal">virtual terminals</a><sup id="cite_ref-FOOTNOTEChristian198811_1-2" class="reference"><a href="#cite_note-FOOTNOTEChristian198811-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup></li>
<li>software <a href="Terminal_emulator" title="Terminal emulator">terminal emulators</a>, such as the <a href="Xterm" title="Xterm">xterm</a>, <a href="Konsole" title="Konsole">Konsole</a>, <a href="GNOME_Terminal" title="GNOME Terminal">GNOME Terminal</a>, and <a href="Terminal_(macOS)" title="Terminal (macOS)">Terminal</a> programs, and network servers such as the <a href="Rlogin" class="mw-redirect" title="Rlogin">rlogin</a> daemon and the <a href="Secure_Shell" title="Secure Shell">SSH</a> daemon, which make use of <a href="Pseudoterminal" title="Pseudoterminal">pseudoterminals</a></li></ul>
<div class="mw-heading mw-heading3"><h3 id="Terminal_intelligence_and_capabilities">Terminal intelligence and capabilities</h3></div>
<div class="mw-heading mw-heading4"><h4 id="Intelligence:_terminals_are_dumb,_not_intelligent">Intelligence: terminals are dumb, not intelligent</h4></div>
<p>Unlike its mainframe and minicomputer contemporaries, the original Unix system was developed solely for <i>dumb</i> terminals, and that remains the case today.<sup id="cite_ref-FOOTNOTECoffin199124_6-0" class="reference"><a href="#cite_note-FOOTNOTECoffin199124-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup> A terminal is a character-oriented device, comprising streams of characters received from and sent to the device.<sup id="cite_ref-FOOTNOTECoffin199124_6-1" class="reference"><a href="#cite_note-FOOTNOTECoffin199124-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman198937&ndash;38_7-0" class="reference"><a href="#cite_note-FOOTNOTELefflerMcKusickKarelsQuarterman198937&ndash;38-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup> Although the streams of characters are structured, incorporating <a href="Control_character" title="Control character">control characters</a>, <a href="Escape_code" class="mw-redirect" title="Escape code">escape codes</a>, and special characters, the I/O protocol is not structured as would be the I/O protocol of <i>smart</i>, or <i><a href="Intelligent_terminal" class="mw-redirect" title="Intelligent terminal">intelligent</a></i>, terminals. There are no field format specifications. There's no block transmission of entire screens (input forms) of input data.
</p><p>By contrast mainframes and minicomputers in closed architectures commonly use <a href="Block-oriented_terminal" class="mw-redirect" title="Block-oriented terminal">Block-oriented terminals</a>.
</p>
<div class="mw-heading mw-heading4"><h4 id="Capabilities:_terminfo,_termcap,_curses,_et_al.">Capabilities: terminfo, termcap, curses, et al.</h4></div>
<style data-mw-deduplicate="TemplateStyles:r1236090951">
/* start https://en.wikipedia.org/ */
.mw-parser-output .hatnote{font-style:italic}.mw-parser-output div.hatnote{padding-left:1.6em;margin-bottom:0.5em}.mw-parser-output .hatnote i{font-style:normal}.mw-parser-output .hatnote+link+.hatnote{margin-top:-0.5em}@media print{body.ns-0 .mw-parser-output .hatnote{display:none!important}}
/* end https://en.wikipedia.org/ */
</style><div role="note" class="hatnote navigation-not-searchable">Main article: <a href="Terminal_capabilities" title="Terminal capabilities">terminal capabilities</a></div>
<p>The "capabilities" of a terminal comprise various dumb terminal features that are above and beyond what is available from a pure teletypewriter, which programs can make use of. They (mainly) comprise escape codes that can be sent to or received from the terminal. The escape codes sent to the terminal perform various functions that a CRT terminal (or software terminal emulator) is capable of that a teletypewriter is not, such as moving the terminal's cursor to positions on the screen, clearing and scrolling all or parts of the screen, turning on and off attached printer devices, programmable function keys, changing display colours and attributes (such as <a href="Reverse_video" title="Reverse video">reverse video</a>), and setting display title strings. The escape codes received from the terminal signify things such as <a href="Function_key" title="Function key">function key</a>, <a href="Arrow_key" class="mw-redirect" title="Arrow key">arrow key</a>, and other special <a href="Typing" title="Typing">keystrokes</a> (<a href="Home_key" title="Home key">home key</a>, <a href="End_key" title="End key">end key</a>, <a href="Help_key" title="Help key">help key</a>, <a href="PgUp_key" class="mw-redirect" title="PgUp key">PgUp key</a>, <a href="PgDn_key" class="mw-redirect" title="PgDn key">PgDn key</a>, <a href="Insert_key" title="Insert key">insert key</a>, <a href="Delete_key" title="Delete key">delete key</a>, and so forth).<sup id="cite_ref-FOOTNOTEAfzal2008419_8-0" class="reference"><a href="#cite_note-FOOTNOTEAfzal2008419-8"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-FOOTNOTEFrisch2002770_9-0" class="reference"><a href="#cite_note-FOOTNOTEFrisch2002770-9"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup>
</p><p>These capabilities are encoded in databases that are configured by a system administrator and accessed from programs via the <a href="Terminfo" title="Terminfo">terminfo</a> library (which supersedes the older <a href="Termcap" title="Termcap">termcap</a> library), upon which in turn are built libraries such as the <a href="Curses_(programming_library)" title="Curses (programming library)">curses</a> and <a href="Ncurses" title="Ncurses">ncurses</a> libraries. Application programs use the terminal capabilities to provide <a href="Textual_user_interface" class="mw-redirect" title="Textual user interface">textual user interfaces</a> with windows, dialogue boxes, buttons, labels, input fields, menus, and so forth.<sup id="cite_ref-FOOTNOTECoffin1991115_10-0" class="reference"><a href="#cite_note-FOOTNOTECoffin1991115-10"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-FOOTNOTECoffin1991372_11-0" class="reference"><a href="#cite_note-FOOTNOTECoffin1991372-11"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading4"><h4 id="Controlling_environment_variables:_TERM_et_al.">Controlling environment variables: <code>TERM</code> et al.</h4></div>
<p>The particular set of capabilities for the terminal that a (terminal-aware) program's input and output uses is obtained from the database rather than hardwired into programs and libraries, and is controlled by the <code>TERM</code> <a href="Environment_variable" title="Environment variable">environment variable</a> (and, optionally for the termcap and terminfo libraries, the <code>TERMCAP</code> and <code>TERMINFO</code> environment variables, respectively).<sup id="cite_ref-FOOTNOTECoffin1991115_10-1" class="reference"><a href="#cite_note-FOOTNOTECoffin1991115-10"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup> This variable is set by whatever <i>terminal monitor</i> program spawns the programs that then use that terminal for its input and output, or sometimes explicitly. For example:
</p>
<ul><li>The <a href="Getty_(Unix)" class="mw-redirect" title="Getty (Unix)">getty</a> program (or equivalent) sets the <code>TERM</code> environment variable according to a system database (variously <a href="Inittab" class="mw-redirect" title="Inittab">inittab</a> or the configuration files for the ttymon or <a href="Launchd" title="Launchd">launchd</a> programs) defining what local terminals are attached to what serial ports and what terminal types are provided by local virtual terminals or the local system console.</li>
<li>A dial-up user on a remote terminal is not using the type of terminal that the system commonly expects on that dial-up line, and so manually sets the <code>TERM</code> environment variable immediately after login to the correct type. (More usually, the terminal type set by the getty program for the dial-up line, that the system administrator has determined to be used most often by dial-up users with remote terminals, matches the one used by the dial-up user and that user has no need to override the terminal type.)</li>
<li>The <a href="Secure_Shell" title="Secure Shell">SSH</a> server daemon (or equivalent such as the <a href="Rlogin" class="mw-redirect" title="Rlogin">rlogin</a> daemon) sets the <code>TERM</code> environment variable to the same terminal type as the SSH client.<sup id="cite_ref-FOOTNOTECoffin1991779_12-0" class="reference"><a href="#cite_note-FOOTNOTECoffin1991779-12"><span class="cite-bracket">[</span>12<span class="cite-bracket">]</span></a></sup></li>
<li>The software terminal emulator, using a pseudoterminal, sets the <code>TERM</code> environment variable to specify the type of terminal that it is emulating. Emulated terminals often do not exactly match real terminal hardware, and terminal emulators have type names dedicated for their use. The xterm program (by default) sets <code>xterm</code> as the terminal type, for example.<sup id="cite_ref-FOOTNOTECoffin1991751&ndash;752_13-0" class="reference"><a href="#cite_note-FOOTNOTECoffin1991751&ndash;752-13"><span class="cite-bracket">[</span>13<span class="cite-bracket">]</span></a></sup> The <a href="GNU_Screen" title="GNU Screen">GNU Screen</a> program sets <code>screen</code> as the terminal type.</li></ul>
<div class="mw-heading mw-heading3"><h3 id="Job_control">Job control</h3></div>
<div role="note" class="hatnote navigation-not-searchable">Main article: <a href="Job_control_(Unix)" title="Job control (Unix)">job control (Unix)</a></div>
<p>Terminals provide job control facilities. Interactively, the user at the terminal can send control characters that suspend the currently running job, reverting to the interactive job control shell that spawned the job, and can run commands that place jobs in the "background" or that switch another, background, job into the foreground (unsuspending it if necessary).<sup id="cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989265_14-0" class="reference"><a href="#cite_note-FOOTNOTELefflerMcKusickKarelsQuarterman1989265-14"><span class="cite-bracket">[</span>14<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989103_15-0" class="reference"><a href="#cite_note-FOOTNOTELefflerMcKusickKarelsQuarterman1989103-15"><span class="cite-bracket">[</span>15<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading3"><h3 id="Line_disciplines">Line disciplines</h3></div>
<div role="note" class="hatnote navigation-not-searchable">Main article: <a href="Line_discipline" title="Line discipline">line discipline</a></div>
<p>Strictly speaking, in Unixes a terminal device comprises the underlying <i>tty device driver</i>, responsible for the physical control of the device hardware via I/O instructions and handling device interrupt requests for character input and output, and the <i>line discipline</i>. A line discipline is independent of the actual device hardware, and the same line discipline can be used for a <a href="Terminal_concentrator" title="Terminal concentrator">terminal concentrator</a> device responsible for multiple controlling terminals as for a pseudoterminal. In fact, the line discipline (or, in the case of BSD, AIX, and other systems, line <i>disciplines</i>) are the same across all terminal devices. It is the line discipline that is responsible for local echo, line editing, processing of input modes, processing of output modes, and character mapping. All these things are independent of the actual hardware, dealing as they do in the simple abstractions provided by tty device drivers: transmit a character, receive a character, set various hardware states.<sup id="cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman198938_16-0" class="reference"><a href="#cite_note-FOOTNOTELefflerMcKusickKarelsQuarterman198938-16"><span class="cite-bracket">[</span>16<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989260&ndash;261_17-0" class="reference"><a href="#cite_note-FOOTNOTELefflerMcKusickKarelsQuarterman1989260&ndash;261-17"><span class="cite-bracket">[</span>17<span class="cite-bracket">]</span></a></sup>
</p><p>In <a href="Seventh_Edition_Unix" class="mw-redirect" title="Seventh Edition Unix">Seventh Edition Unix</a>, <a href="BSD" class="mw-redirect" title="BSD">BSD</a> systems and derivatives including <a href="MacOS" title="MacOS">macOS</a>, and <a href="Linux" title="Linux">Linux</a>, each terminal device can be switched amongst multiple line disciplines.<sup id="cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989262_18-0" class="reference"><a href="#cite_note-FOOTNOTELefflerMcKusickKarelsQuarterman1989262-18"><span class="cite-bracket">[</span>18<span class="cite-bracket">]</span></a></sup> In the AT&T <a href="STREAMS" title="STREAMS">STREAMS</a> system, line disciplines are STREAMS modules that may be pushed onto and popped off a STREAMS I/O stack.<sup id="cite_ref-FOOTNOTEChristian1988395_19-0" class="reference"><a href="#cite_note-FOOTNOTEChristian1988395-19"><span class="cite-bracket">[</span>19<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="History">History</h2></div>
<p>The POSIX terminal interface is derived from the terminal interfaces of various Unix systems.
</p>
<div class="mw-heading mw-heading3"><h3 id="Early_Unixes:_Seventh_Edition_Unix">Early Unixes: Seventh Edition Unix</h3></div>
<div role="note" class="hatnote navigation-not-searchable">Main article: <a href="Seventh_Edition_Unix_terminal_interface" title="Seventh Edition Unix terminal interface">Seventh Edition Unix terminal interface</a></div>
<p>The terminal interface provided by Unix 32V and Seventh Edition Unix, and also presented by BSD version 4 as the <i>old terminal driver</i>, was a simple one, largely geared towards teletypewriters as terminals. Input was entered a line at a time, with the terminal driver in the operating system (and not the terminals themselves) providing simple line editing capabilities. A buffer was maintained by the kernel in which editing took place. Applications reading terminal input would receive the contents of the buffer only when the <style data-mw-deduplicate="TemplateStyles:r1249182868">
/* start https://en.wikipedia.org/ */
.mw-parser-output .keyboard-key{border:1px solid #aaa;border-radius:0.2em;box-shadow:0.1em 0.1em 0.2em rgba(0,0,0,0.1);background-color:var(--background-color-neutral-subtle,#f8f9fa);background-image:linear-gradient(to bottom,var(--background-color-neutral,#eaecf0),var(--background-color-neutral-subtle,#f8f9fa),var(--background-color-neutral,#eaecf0));color:var(--color-base,#202122);padding:0.1em 0.3em;font-family:inherit;font-size:0.85em}
/* end https://en.wikipedia.org/ */
</style><kbd class="keyboard-key nowrap">return</kbd> key was pressed on the terminal to end line editing. The <kbd class="keyboard-key nowrap">@</kbd> key sent from the terminal to the system would erase ("kill") the entire current contents of the editing buffer, and would be normally displayed as an '<style data-mw-deduplicate="TemplateStyles:r886049734">
/* start https://en.wikipedia.org/ */
.mw-parser-output .monospaced{font-family:monospace,monospace}
/* end https://en.wikipedia.org/ */
</style><span class="monospaced">@</span>' symbol followed by a newline sequence to move the print position to a fresh blank line. The <kbd class="keyboard-key nowrap">#</kbd> key sent from the terminal to the system would erase the last character from the end of the editing buffer, and would be normally displayed as an '<span class="monospaced">#</span>' symbol, which users would have to recognize as denoting a "rubout" of the preceding character (teletypewriters not being physically capable of erasing characters once they have been printed on the paper).<sup id="cite_ref-FOOTNOTEBourne19838_20-0" class="reference"><a href="#cite_note-FOOTNOTEBourne19838-20"><span class="cite-bracket">[</span>20<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-FOOTNOTEBourne1983130&ndash;131_21-0" class="reference"><a href="#cite_note-FOOTNOTEBourne1983130&ndash;131-21"><span class="cite-bracket">[</span>21<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-FOOTNOTEBourne1983287_22-0" class="reference"><a href="#cite_note-FOOTNOTEBourne1983287-22"><span class="cite-bracket">[</span>22<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-FOOTNOTEChristian198826_23-0" class="reference"><a href="#cite_note-FOOTNOTEChristian198826-23"><span class="cite-bracket">[</span>23<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989262_18-1" class="reference"><a href="#cite_note-FOOTNOTELefflerMcKusickKarelsQuarterman1989262-18"><span class="cite-bracket">[</span>18<span class="cite-bracket">]</span></a></sup>
</p><p>From a programming point of view, a terminal device had transmit and receive <a href="Baud_rate" class="mw-redirect" title="Baud rate">baud rates</a>, "erase" and "kill" characters (that performed line editing, as explained), "interrupt" and "quit" characters (generating <a href="Unix_signal" class="mw-redirect" title="Unix signal">signals</a> to all of the processes for which the terminal was a controlling terminal), "start" and "stop" characters (used for <a href="Modem_flow_control" class="mw-redirect" title="Modem flow control">modem flow control</a>), an "end of file" character (acting like a carriage return except discarded from the buffer by the <code>read()</code> system call and therefore potentially causing a zero-length result to be returned) and various <i>basic mode flags</i> determining whether <a href="Local_echo" class="mw-redirect" title="Local echo">local echo</a> was emulated by the kernel's terminal driver, whether modem flow control was enabled, the lengths of various output delays, mapping for the carriage return character, and the three input modes.<sup id="cite_ref-FOOTNOTEBourne1983132&ndash;133_24-0" class="reference"><a href="#cite_note-FOOTNOTEBourne1983132&ndash;133-24"><span class="cite-bracket">[</span>24<span class="cite-bracket">]</span></a></sup>
</p><p>The three input modes were:
</p>
<dl><dt>line mode (also called "cooked" mode)</dt>
<dd></dd></dl>
<div role="note" class="hatnote navigation-not-searchable">Main article: <a href="Cooked_mode" class="mw-redirect" title="Cooked mode">cooked mode</a></div>
<p>In line mode the line discipline performs all line editing functions and recognizes the "interrupt" and "quit" control characters and transforms them into signals sent to processes. Applications programs reading from the terminal receive entire lines, after line editing has been completed by the user pressing return.<sup id="cite_ref-FOOTNOTEBourne1983130&ndash;131_21-1" class="reference"><a href="#cite_note-FOOTNOTEBourne1983130&ndash;131-21"><span class="cite-bracket">[</span>21<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989259&ndash;260_25-0" class="reference"><a href="#cite_note-FOOTNOTELefflerMcKusickKarelsQuarterman1989259&ndash;260-25"><span class="cite-bracket">[</span>25<span class="cite-bracket">]</span></a></sup>
</p>
<dl><dt>cbreak mode</dt>
<dd></dd></dl>
<div role="note" class="hatnote navigation-not-searchable">Main article: <a href="Cbreak_mode" class="mw-redirect" title="Cbreak mode">cbreak mode</a></div>
<p>cbreak mode is one of two character-at-a-time modes. (<a href="Stephen_R._Bourne" title="Stephen R. Bourne">Stephen R. Bourne</a> jokingly referred to it (<a href="#CITEREFBourne1983">Bourne 1983</a>, p. 288) as a "half-cooked" and therefore "rare" mode.) The line discipline performs no line editing, and the control sequences for line editing functions are treated as normal character input. Applications programs reading from the terminal receive characters immediately, as soon as they are available in the <a href="Input_queue" title="Input queue">input queue</a> to be read. However, the "interrupt" and "quit" control characters, as well as modem flow control characters, are still handled specially and stripped from the input stream.<sup id="cite_ref-FOOTNOTEBourne1983288_26-0" class="reference"><a href="#cite_note-FOOTNOTEBourne1983288-26"><span class="cite-bracket">[</span>26<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989260_27-0" class="reference"><a href="#cite_note-FOOTNOTELefflerMcKusickKarelsQuarterman1989260-27"><span class="cite-bracket">[</span>27<span class="cite-bracket">]</span></a></sup>
</p>
<dl><dt>raw mode</dt>
<dd>raw mode is the other of the two character-at-a-time modes. The line discipline performs no line editing, and the control sequences for both line editing functions and the various special characters ("interrupt", "quit", and flow control) are treated as normal character input. Applications programs reading from the terminal receive characters immediately, and receive the entire character stream unaltered, just as it came from the terminal device itself.<sup id="cite_ref-FOOTNOTEBourne1983132_28-0" class="reference"><a href="#cite_note-FOOTNOTEBourne1983132-28"><span class="cite-bracket">[</span>28<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-FOOTNOTEBourne1983288_26-1" class="reference"><a href="#cite_note-FOOTNOTEBourne1983288-26"><span class="cite-bracket">[</span>26<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989260_27-1" class="reference"><a href="#cite_note-FOOTNOTELefflerMcKusickKarelsQuarterman1989260-27"><span class="cite-bracket">[</span>27<span class="cite-bracket">]</span></a></sup></dd></dl>
<p>The programmatic interface for querying and modifying all of these modes and control characters was the <a href="Ioctl" title="Ioctl"><code>ioctl()</code> system call</a>. (This replaced the <code>stty()</code> and <code>gtty()</code> system calls of Sixth Edition Unix.)<sup id="cite_ref-FOOTNOTEBourne1983133_29-0" class="reference"><a href="#cite_note-FOOTNOTEBourne1983133-29"><span class="cite-bracket">[</span>29<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-FOOTNOTEChristian1988393_30-0" class="reference"><a href="#cite_note-FOOTNOTEChristian1988393-30"><span class="cite-bracket">[</span>30<span class="cite-bracket">]</span></a></sup> Although the "erase" and "kill" characters were modifiable from their defaults of <kbd class="keyboard-key nowrap">#</kbd> and <kbd class="keyboard-key nowrap">@</kbd>, for many years they were the pre-set defaults in the terminal device drivers, and on many Unix systems, which only altered terminal device settings as part of the login process, in system login scripts that ran <i>after</i> the user had entered username and password, any mistakes at the login and password prompts had to be corrected using the historical editing key characters inherited from teletypewriter terminals.<sup id="cite_ref-FOOTNOTEChristian198826_23-1" class="reference"><a href="#cite_note-FOOTNOTEChristian198826-23"><span class="cite-bracket">[</span>23<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading3"><h3 id="BSD:_the_advent_of_job_control">BSD: the advent of job control</h3></div>
<div role="note" class="hatnote navigation-not-searchable">See also: <a href="Job_control_(Unix)" title="Job control (Unix)">Job control (Unix)</a></div>
<p>With the BSD Unixes came <a href="Job_control_(Unix)" title="Job control (Unix)">job control</a>, and a <i>new terminal driver</i> with extended capabilities.<sup id="cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989262_18-2" class="reference"><a href="#cite_note-FOOTNOTELefflerMcKusickKarelsQuarterman1989262-18"><span class="cite-bracket">[</span>18<span class="cite-bracket">]</span></a></sup> These extensions comprised additional (again programmatically modifiable) special characters:
</p>
<ul><li>The "suspend" and "delayed suspend" characters (by default <kbd class="keyboard-key nowrap">Control</kbd>+<kbd class="keyboard-key nowrap">Z</kbd> and <kbd class="keyboard-key nowrap">Control</kbd>+<kbd class="keyboard-key nowrap">Y</kbd> — ASCII <a href="Substitute_character" title="Substitute character"><code>SUB</code></a> and <a href="End_of_Medium" class="mw-redirect" title="End of Medium"><code>EM</code></a>) caused the generation of a new <code><a href="SIGTSTP" class="mw-redirect" title="SIGTSTP">SIGTSTP</a></code> signal to processes in the terminal's controlling process group.<sup id="cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989260_27-2" class="reference"><a href="#cite_note-FOOTNOTELefflerMcKusickKarelsQuarterman1989260-27"><span class="cite-bracket">[</span>27<span class="cite-bracket">]</span></a></sup></li>
<li>The "word erase", "literal next", and "reprint" characters (by default <kbd class="keyboard-key nowrap">Control</kbd>+<kbd class="keyboard-key nowrap">W</kbd>, <kbd class="keyboard-key nowrap">Control</kbd>+<kbd class="keyboard-key nowrap">V</kbd>, and <kbd class="keyboard-key nowrap">Control</kbd>+<kbd class="keyboard-key nowrap">R</kbd> — ASCII <a href="End_Transmission_Block_character" class="mw-redirect" title="End Transmission Block character"><code>ETB</code></a>, <a href="Synchronous_idle" class="mw-redirect" title="Synchronous idle"><code>SYN</code></a>, and <a href="C0_and_C1_control_codes#ASCII" title="C0 and C1 control codes"><code>DC2</code></a>) performed additional line editing functions. "word erase" erased the last word at the end of the line editing buffer. "literal next" allowed any special character to be entered into the line editing buffer (a function available, somewhat inconveniently, in Seventh Edition Unix via the backslash character). "reprint" caused the line discipline to reprint the current contents of the line editing buffer on a new line (useful for when another, background, process had generated output that had intermingled with line editing).<sup id="cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989260_27-3" class="reference"><a href="#cite_note-FOOTNOTELefflerMcKusickKarelsQuarterman1989260-27"><span class="cite-bracket">[</span>27<span class="cite-bracket">]</span></a></sup></li></ul>
<p>The programmatic interface for querying and modifying all of these extra modes and control characters was still the <code>ioctl()</code> system call, which its creators (<a href="#CITEREFLefflerMcKusickKarelsQuarterman1989">Leffler et al. 1989</a>, p. 262) described as a "rather cluttered interface". All of the original Seventh Edition Unix functionality was retained, and the new functionality was added via additional <code>ioctl()</code> operation codes, resulting in a programmatic interface that had clearly grown, and that presented some duplication of functionality.<sup id="cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989262&ndash;263_31-0" class="reference"><a href="#cite_note-FOOTNOTELefflerMcKusickKarelsQuarterman1989262&ndash;263-31"><span class="cite-bracket">[</span>31<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading3"><h3 id="System_III_and_System_V">System III and System V</h3></div>
<p><a href="System_III" class="mw-redirect" title="System III">System III</a> introduced a new programming interface that combined Seventh Edition's separate <code>ioctl()</code> operations to get and set flags and to get and set control characters into calls that used a <code>termio</code> structure to hold both flags and control characters and that could get them in a single operation and set them in another single operation. It also split some of the flags from the Seventh Edition interface into multiple separate flags, and added some additional capabilities, although it did not support job control or the cooked-mode enhancements of 4BSD.<sup id="cite_ref-32" class="reference"><a href="#cite_note-32"><span class="cite-bracket">[</span>32<span class="cite-bracket">]</span></a></sup> For example, it replaced the "cooked", "cbreak", and "raw" modes of Seventh Edition with different abstractions. The recognition of signal-generating characters is independent of input mode, and there are only the two input modes: canonical and non-canonical. (This allows a terminal input mode not present in Seventh Edition and BSD: canonical mode with signal generation disabled.)
</p><p>System III's successors, including <a href="System_V" class="mw-redirect" title="System V">System V</a>, used the same interface.
</p>
<div class="mw-heading mw-heading3"><h3 id="POSIX:_Consolidation_and_abstraction">POSIX: Consolidation and abstraction</h3></div>
<p>One of the major problems that the POSIX standard addressed with its definition of a general terminal interface was the plethora of programmatic interfaces. Although by the time of the standard the behaviour of terminals was fairly uniform from system to system, most Unixes having adopted the notions of line disciplines and the BSD job control capabilities, the programmatic interface to terminals via the <code>ioctl()</code> system call was a mess. Different Unixes supplied different <code>ioctl()</code> operations, with different (symbolic) names, and different flags. Portable source code had to contain a significant amount of conditional compilation to accommodate the differences across software platforms, even though they were all notionally Unix.<sup id="cite_ref-FOOTNOTEZlotnick1991157_33-0" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991157-33"><span class="cite-bracket">[</span>33<span class="cite-bracket">]</span></a></sup>
</p><p>The POSIX standard replaces the <code>ioctl()</code> system entirely, with a set of library functions (which, of course, may be <i>implemented</i> under the covers via platform-specific <code>ioctl()</code> operations) with standardized names and parameters. The <code>termio</code> data structure of System V Unix was used as a template for the POSIX <code>termios</code> data structure, whose fields were largely unchanged except that they now used alias data types for specifying the fields, allowing them to be easily ported across multiple processor architectures by implementors, rather than explicitly requiring the <code>unsigned short</code> and <code>char</code> data types of the C and C++ programming languages (which might be inconvenient sizes on some processor architectures).<sup id="cite_ref-FOOTNOTEZlotnick1991157_33-1" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991157-33"><span class="cite-bracket">[</span>33<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-FOOTNOTEZlotnick1991163_34-0" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991163-34"><span class="cite-bracket">[</span>34<span class="cite-bracket">]</span></a></sup>
</p><p>POSIX also introduced support for job control, with the <code>termios</code> structure containing suspend and delayed-suspend characters in addition to the control characters supported by System III and System V. It did not add any of the cooked-mode extensions from BSD, although <a href="SunOS" title="SunOS">SunOS</a> 4.x, <a href="System_V_Release_4" class="mw-redirect" title="System V Release 4">System V Release 4</a>, <a href="Solaris_(operating_system)" class="mw-redirect" title="Solaris (operating system)">Solaris</a>, <a href="HP-UX" title="HP-UX">HP-UX</a>, <a href="AIX" class="mw-redirect" title="AIX">AIX</a>, newer BSDs, <a href="MacOS" title="MacOS">macOS</a>, and <a href="Linux" title="Linux">Linux</a> have implemented them as extensions to <code>termios</code>.
</p>
<div class="mw-heading mw-heading2"><h2 id="What_the_standard_defines">What the standard defines</h2></div>
<div class="mw-heading mw-heading3"><h3 id="Controlling_terminals_and_process_groups">Controlling terminals and process groups</h3></div>
<div role="note" class="hatnote navigation-not-searchable">Further information: <a href="Process_group" title="Process group">Process group</a></div>
<p>Each <a href="Process_(computing)" title="Process (computing)">process</a> in the system has either a single <i>controlling terminal</i>, or no controlling terminal at all. A process inherits its controlling terminal from its parent, and the only operations upon a process are acquiring a controlling terminal, by a process that has no controlling terminal, and relinquishing it, by a process that has a controlling terminal.<sup id="cite_ref-FOOTNOTEZlotnick1991157_33-2" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991157-33"><span class="cite-bracket">[</span>33<span class="cite-bracket">]</span></a></sup>
</p><p>No portable way of acquiring a controlling terminal is defined, the method being implementation defined. The standard defines the <code>O_NOCTTY</code> flag for the <a href="Open_(system_call)" title="Open (system call)"><code>open()</code> system call</a>, which is the way of <i>preventing</i> what is otherwise the conventional way of acquiring a controlling terminal (a process with no controlling terminal <code>open()</code>s a terminal device file that isn't already the controlling terminal for some other process, without specifying the <code>O_NOCTTY</code> flag<sup id="cite_ref-FOOTNOTEBourne1983130_35-0" class="reference"><a href="#cite_note-FOOTNOTEBourne1983130-35"><span class="cite-bracket">[</span>35<span class="cite-bracket">]</span></a></sup>) but leaves its conventional semantics optional.
</p><p>Each process also is a member of a process group. Each terminal device records a process group that is termed its <i>foreground process group</i>. The process groups control terminal access and signal delivery. Signals generated at the terminal are sent to all processes that are members of the terminal's foreground process group. <a href="Read_(system_call)" title="Read (system call)"><code>read()</code></a> and <a href="Write_(system_call)" title="Write (system call)"><code>write()</code></a> I/O operations on a terminal by a process that is not a member of the terminal's foreground process group will and may optionally (respectively) cause signals (<code><a href="SIGTTIN" class="mw-redirect" title="SIGTTIN">SIGTTIN</a></code> and <code><a href="SIGTTOU" class="mw-redirect" title="SIGTTOU">SIGTTOU</a></code> respectively) to be sent to the invoking process. Various terminal-mode-altering library functions have the same behaviour as <code>write()</code>, except that they always generate the signals, even if that functionality is turned off for <code>write()</code> itself.<sup id="cite_ref-FOOTNOTEZlotnick1991158_36-0" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991158-36"><span class="cite-bracket">[</span>36<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-FOOTNOTEZlotnick1991173&ndash;174_37-0" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991173&ndash;174-37"><span class="cite-bracket">[</span>37<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading3"><h3 id="The_termios_data_structure">The <code>termios</code> data structure</h3></div><p>
The data structure used by all of the terminal library calls is the <code>termios</code> structure,<sup id="cite_ref-FOOTNOTEZlotnick1991162_38-0" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991162-38"><span class="cite-bracket">[</span>38<span class="cite-bracket">]</span></a></sup> whose C and C++ programming language definition is as follows:<sup id="cite_ref-FOOTNOTEZlotnick1991163_34-1" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991163-34"><span class="cite-bracket">[</span>34<span class="cite-bracket">]</span></a></sup></p><div class="mw-highlight mw-highlight-lang-c mw-content-ltr" dir="ltr"><pre><span class="k">struct</span><span class="w"> </span><span class="nc">termios</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">tcflag_t</span><span class="w"> </span><span class="n">c_iflag</span><span class="w"> </span><span class="p">;</span><span class="w"> </span><span class="c1">// Input modes</span>
<span class="w"> </span><span class="n">tcflag_t</span><span class="w"> </span><span class="n">c_oflag</span><span class="w"> </span><span class="p">;</span><span class="w"> </span><span class="c1">// Output modes</span>
<span class="w"> </span><span class="n">tcflag_t</span><span class="w"> </span><span class="n">c_cflag</span><span class="w"> </span><span class="p">;</span><span class="w"> </span><span class="c1">// Control modes</span>
<span class="w"> </span><span class="n">tcflag_t</span><span class="w"> </span><span class="n">c_lflag</span><span class="w"> </span><span class="p">;</span><span class="w"> </span><span class="c1">// Local modes</span>
<span class="w"> </span><span class="n">cc_t</span><span class="w"> </span><span class="n">c_cc</span><span class="p">[</span><span class="n">NCCS</span><span class="p">]</span><span class="w"> </span><span class="p">;</span><span class="w"> </span><span class="c1">// Control characters</span>
<span class="p">}</span><span class="w"> </span><span class="p">;</span>
</pre></div>
<p>The order of the fields within the <code>termios</code> structure is not defined, and implementations are allowed to add non-standard fields.<sup id="cite_ref-FOOTNOTEZlotnick1991163_34-2" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991163-34"><span class="cite-bracket">[</span>34<span class="cite-bracket">]</span></a></sup> Indeed, implementations have to add non-standard fields for recording input and output baud rates. These are recorded in the structure, in an implementation-defined form, and accessed via accessor functions, rather than by direct manipulation of the field values, as is the case for the standardized structure fields.<sup id="cite_ref-FOOTNOTEZlotnick1991166_39-0" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991166-39"><span class="cite-bracket">[</span>39<span class="cite-bracket">]</span></a></sup>
</p><p>The data type aliases <code>tcflag_t</code> and <code>cc_t</code>, as well as the symbolic constant <code>NCCS</code> and symbolic constants for the various mode flags, control character names, and baud rates, are all defined in a standard header <code>termios.h</code>. (This is not to be confused with the similarly named header <code>termio.h</code> from System III and System V, which defines a similar <code>termio</code> structure and a lot of similarly named symbolic constants. This interface is specific to System III and System V, and code that uses it will not necessarily be portable to other systems.)<sup id="cite_ref-FOOTNOTEZlotnick1991162&ndash;163_40-0" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991162&ndash;163-40"><span class="cite-bracket">[</span>40<span class="cite-bracket">]</span></a></sup>
</p><p>The structure's fields are (in summary, for details see the main article):
</p>
<dl><dt><code>c_iflag</code></dt>
<dd>input mode flags for controlling input parity, input newline translation, modem <a href="Flow_control_(data)" title="Flow control (data)">flow control</a>, <a href="8-bit_clean" title="8-bit clean">8-bit cleanliness</a>, and response to a (serial port's) <a href="Universal_asynchronous_receiver/transmitter" class="mw-redirect" title="Universal asynchronous receiver/transmitter">"break" condition</a><sup id="cite_ref-FOOTNOTEZlotnick1991163_34-3" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991163-34"><span class="cite-bracket">[</span>34<span class="cite-bracket">]</span></a></sup></dd>
<dt><code>c_oflag</code></dt>
<dd>output mode flags for controlling implementation-defined output postprocessing, output newline translation, and output delays after various control characters have been sent<sup id="cite_ref-FOOTNOTEZlotnick1991164_41-0" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991164-41"><span class="cite-bracket">[</span>41<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989260_27-4" class="reference"><a href="#cite_note-FOOTNOTELefflerMcKusickKarelsQuarterman1989260-27"><span class="cite-bracket">[</span>27<span class="cite-bracket">]</span></a></sup></dd>
<dt><code>c_cflag</code></dt>
<dd>terminal hardware control flags for controlling the actual terminal device rather than the line discipline: the number of bits in a character, parity type, hangup control, and serial line flow control<sup id="cite_ref-FOOTNOTEZlotnick1991165_42-0" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991165-42"><span class="cite-bracket">[</span>42<span class="cite-bracket">]</span></a></sup></dd>
<dt><code>c_lflag</code></dt>
<dd>local control flags for controlling the line discipline rather than the terminal hardware: canonical mode, echo modes, signal-generation character recognition and handling, and enabling the generation of the <code>SIGTTOU</code> signal by the <code>write()</code> system call<sup id="cite_ref-FOOTNOTEZlotnick1991166_39-1" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991166-39"><span class="cite-bracket">[</span>39<span class="cite-bracket">]</span></a></sup></dd></dl>
<p>The library functions are (in summary, for details see the main article):
</p>
<dl><dt><code>tcgetattr()</code></dt>
<dd>query a terminal device's current attribute settings into a <code>termios</code> structure<sup id="cite_ref-FOOTNOTEZlotnick1991167_43-0" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991167-43"><span class="cite-bracket">[</span>43<span class="cite-bracket">]</span></a></sup></dd>
<dt><code>tcsetattr()</code></dt>
<dd>set a terminal device's current attribute settings from a <code>termios</code> structure, optionally waiting for queued output to drain and flushing queued input<sup id="cite_ref-FOOTNOTEZlotnick1991167_43-1" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991167-43"><span class="cite-bracket">[</span>43<span class="cite-bracket">]</span></a></sup></dd>
<dt><code>cfgetispeed()</code></dt>
<dd>query the input baud rate from the implementation-defined fields in a <code>termios</code> structure<sup id="cite_ref-FOOTNOTEZlotnick1991169_44-0" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991169-44"><span class="cite-bracket">[</span>44<span class="cite-bracket">]</span></a></sup></dd>
<dt><code>cfgetospeed()</code></dt>
<dd>query the output baud rate from the implementation-defined fields in a <code>termios</code> structure<sup id="cite_ref-FOOTNOTEZlotnick1991169_44-1" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991169-44"><span class="cite-bracket">[</span>44<span class="cite-bracket">]</span></a></sup></dd>
<dt><code>cfsetispeed()</code></dt>
<dd>set the input baud rate in the implementation-defined fields in a <code>termios</code> structure<sup id="cite_ref-FOOTNOTEZlotnick1991169_44-2" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991169-44"><span class="cite-bracket">[</span>44<span class="cite-bracket">]</span></a></sup></dd>
<dt><code>cfsetospeed()</code></dt>
<dd>set the output baud rate in the implementation-defined fields in a <code>termios</code> structure<sup id="cite_ref-FOOTNOTEZlotnick1991169_44-3" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991169-44"><span class="cite-bracket">[</span>44<span class="cite-bracket">]</span></a></sup></dd>
<dt><code>tcsendbreak()</code></dt>
<dd>send a modem "break" signal on a serial device terminal<sup id="cite_ref-FOOTNOTEZlotnick1991172_45-0" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991172-45"><span class="cite-bracket">[</span>45<span class="cite-bracket">]</span></a></sup></dd>
<dt><code>tcdrain()</code></dt>
<dd>wait for queued output to drain<sup id="cite_ref-FOOTNOTEZlotnick1991172_45-1" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991172-45"><span class="cite-bracket">[</span>45<span class="cite-bracket">]</span></a></sup></dd>
<dt><code>tcflush()</code></dt>
<dd>discard queued input<sup id="cite_ref-FOOTNOTEZlotnick1991172_45-2" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991172-45"><span class="cite-bracket">[</span>45<span class="cite-bracket">]</span></a></sup></dd>
<dt><code>tcflow()</code></dt>
<dd>change flow control<sup id="cite_ref-FOOTNOTEZlotnick1991172_45-3" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991172-45"><span class="cite-bracket">[</span>45<span class="cite-bracket">]</span></a></sup></dd>
<dt><code>tcgetpgrp()</code></dt>
<dd>query the terminal's foreground process group<sup id="cite_ref-FOOTNOTEZlotnick1991174_46-0" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991174-46"><span class="cite-bracket">[</span>46<span class="cite-bracket">]</span></a></sup></dd>
<dt><code>tcsetpgrp()</code></dt>
<dd>set the terminal's foreground process group<sup id="cite_ref-FOOTNOTEZlotnick1991174_46-1" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991174-46"><span class="cite-bracket">[</span>46<span class="cite-bracket">]</span></a></sup></dd></dl>
<div class="mw-heading mw-heading3"><h3 id="Special_characters">Special characters</h3></div>
<table class="wikitable" style="float:right;" width="40%">
<caption>Programmatically modifiable special characters<sup id="cite_ref-FOOTNOTEZlotnick1991159_47-0" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991159-47"><span class="cite-bracket">[</span>47<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-FOOTNOTEZlotnick1991169_44-4" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991169-44"><span class="cite-bracket">[</span>44<span class="cite-bracket">]</span></a></sup>
</caption>
<tbody><tr>
<th>Field</th>
<th>meaning</th>
<th>Retrieved by <code>read()</code></th>
<th>Notes
</th></tr>
<tr>
<td><code>c_cc[VEOF]</code></td>
<td>end of file</td>
<td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No</td>
<td>Only processed by canonical mode line editing
</td></tr>
<tr>
<td><code>c_cc[VEOL]</code></td>
<td>end of line</td>
<td style="background:#9EFF9E;color:black;vertical-align:middle;text-align:center;" class="table-yes">Yes</td>
<td>Only processed by canonical mode line editing
</td></tr>
<tr>
<td><code>c_cc[VERASE]</code></td>
<td>"erase"</td>
<td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No</td>
<td>Only processed by canonical mode line editing
</td></tr>
<tr>
<td><code>c_cc[VKILL]</code></td>
<td>"kill"</td>
<td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No</td>
<td>Only processed by canonical mode line editing
</td></tr>
<tr>
<td><code>c_cc[VINTR]</code></td>
<td>"interrupt"</td>
<td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No</td>
<td>Signal-generation character independent of input mode
</td></tr>
<tr>
<td><code>c_cc[VQUIT]</code></td>
<td>"quit"</td>
<td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No</td>
<td>Signal-generation character independent of input mode
</td></tr>
<tr>
<td><code>c_cc[VSUSP]</code></td>
<td>"suspend"</td>
<td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No</td>
<td>Signal-generation character independent of input mode
</td></tr>
<tr>
<td><code>c_cc[VSTOP]</code></td>
<td>"stop"</td>
<td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No</td>
<td>Modem flow control character independent of input mode
</td></tr>
<tr>
<td><code>c_cc[VSTART]</code></td>
<td>"start"</td>
<td style="background:#FFC7C7;color:black;vertical-align:middle;text-align:center;" class="table-no">No</td>
<td>Modem flow control character independent of input mode
</td></tr></tbody></table>
<p>The <code>c_cc[]</code> array member of the <code>termios</code> data structure specifies all of the (programmatically modifiable) special characters. The indexes into the array are symbolic constants, one for each special character type, as in the table at right. (Two further entries in the array are relevant to non-canonical mode input processing and are discussed below.)<sup id="cite_ref-FOOTNOTEZlotnick1991167_43-2" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991167-43"><span class="cite-bracket">[</span>43<span class="cite-bracket">]</span></a></sup>
</p><p>Non-programmatically modifiable special characters are <i>linefeed</i> (ASCII <code>LF</code>) and <i>carriage return</i> (ASCII <code>CR</code>).<sup id="cite_ref-FOOTNOTEZlotnick1991159_47-1" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991159-47"><span class="cite-bracket">[</span>47<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading3"><h3 id="Input_processing">Input processing</h3></div>
<p>Input processing determines the behaviour of the <code>read()</code> system call on a terminal device and the line editing and signal-generation characteristics of the line discipline. Unlike the case of Seventh Edition Unix and BSD version 4, and like the case of System III and System V, line editing operates in one of just two modes: canonical mode and non-canonical mode. The basic difference between them is when, from the point of view of the blocking/non-blocking requirements of the <code>read()</code> system call (specified with the <code>O_NONBLOCK</code> flag on the <a href="File_descriptor" title="File descriptor">file descriptor</a> via <code>open()</code> or <code>fcntl()</code>), data "are available for reading".<sup id="cite_ref-FOOTNOTEZlotnick1991160_48-0" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991160-48"><span class="cite-bracket">[</span>48<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading4"><h4 id="Canonical_mode_processing">Canonical mode processing</h4></div>
<p>In canonical mode, data are accumulated in a line editing buffer, and do not become "available for reading" until line editing has been terminated by the user (at the terminal) sending a <i>line delimiter character</i>. Line delimiter characters are special characters, and they are <i>end of file</i>, <i>end of line</i>, and <i>linefeed</i> (ASCII <code>LF</code>). The former two are settable programmatically, whilst the latter is fixed. The latter two are included in the line editing buffer, whilst the former one is not.<sup id="cite_ref-FOOTNOTEZlotnick1991160&ndash;161_49-0" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991160&ndash;161-49"><span class="cite-bracket">[</span>49<span class="cite-bracket">]</span></a></sup>
</p><p>More strictly, zero or more lines are accumulated in the line editing buffer, separated by line delimiters (which may or may not be discarded once <code>read()</code> comes around to reading them), and line editing operates upon the part of the line editing buffer that follows the last (if any) line delimiter in the buffer. So, for example, the "erase" character (whatever that has been programmed to be) will erase the last character in the line buffer only up to (but not including) a preceding line delimiter.<sup id="cite_ref-FOOTNOTEZlotnick1991160&ndash;161_49-1" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991160&ndash;161-49"><span class="cite-bracket">[</span>49<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading4"><h4 id="Non-canonical_mode_processing">Non-canonical mode processing</h4></div>
<p>In non-canonical mode, data are accumulated in a buffer (which may or may not be the line editing buffer — some implementations having separate "processed input" and "raw input" queues) and become "available for reading" according to the values of two input control parameters, the <code>c_cc[MIN]</code> and <code>c_cc[TIME]</code> members of the <code>termios</code> data structure. Both are unsigned quantities (because <code>cc_t</code> is required to be an alias for an unsigned type). The former specifies a minimum number of characters, and the latter specifies a timeout in tenths of a second.<sup id="cite_ref-FOOTNOTEZlotnick1991161_50-0" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991161-50"><span class="cite-bracket">[</span>50<span class="cite-bracket">]</span></a></sup> There are four possibilities:
</p>
<dl><dt><code>c_cc[TIME]</code> and <code>c_cc[MIN]</code> are both zero</dt>
<dd>In this case, the data in the buffer are "available for reading" immediately, and <code>read()</code> returns immediately with whatever data are in the buffer (potentially returning zero if there are zero data available).<sup id="cite_ref-FOOTNOTEZlotnick1991161&ndash;162_51-0" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991161&ndash;162-51"><span class="cite-bracket">[</span>51<span class="cite-bracket">]</span></a></sup></dd>
<dt><code>c_cc[TIME]</code> is non-zero and <code>c_cc[MIN]</code> is zero</dt>
<dd>In this case, the data in the buffer are "available for reading" after the specified timeout has elapsed, the timer being triggered by the start of the <code>read()</code> system call, or if a single character is received. In other words, <code>read()</code> waits for a maximum specified total time, and may return zero data, and returns any data as soon as they are received.<sup id="cite_ref-FOOTNOTEZlotnick1991161&ndash;162_51-1" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991161&ndash;162-51"><span class="cite-bracket">[</span>51<span class="cite-bracket">]</span></a></sup></dd>
<dt><code>c_cc[TIME]</code> is zero and <code>c_cc[MIN]</code> is non-zero</dt>
<dd>In this case, the data in the buffer are "available for reading" after the specified number of characters have been received in the buffer. In other words, <code>read()</code> waits for a minimum amount of data (which may be larger than what the caller is prepared to read in the system call), will not return zero data, and may wait indefinitely.<sup id="cite_ref-FOOTNOTEZlotnick1991161&ndash;162_51-2" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991161&ndash;162-51"><span class="cite-bracket">[</span>51<span class="cite-bracket">]</span></a></sup></dd>
<dt><code>c_cc[TIME]</code> and <code>c_cc[MIN]</code> are both non-zero</dt>
<dd>In this case, the data in the buffer are "available for reading" after the specified number of characters have been received in the buffer or the timeout has expired since the last character was entered. There is no timeout for the very first character. In other words, <code>read()</code> waits for a minimum amount of data (which may be larger than what the caller is prepared to read in the system call), will not return zero data, may wait indefinitely, but won't wait longer than the specified timeout if at least one character is in the buffer to be read.<sup id="cite_ref-FOOTNOTEZlotnick1991161&ndash;162_51-3" class="reference"><a href="#cite_note-FOOTNOTEZlotnick1991161&ndash;162-51"><span class="cite-bracket">[</span>51<span class="cite-bracket">]</span></a></sup></dd></dl>
<div class="mw-heading mw-heading3"><h3 id="Output_processing">Output processing</h3></div>
<p>Output processing is largely unchanged from its System III/System V roots. Output mode control flags determine various options:
</p>
<ul><li><a href="Carriage_return" title="Carriage return">Carriage returns</a> may be inserted before each linefeed character, to translate Unix newline semantics to the ASCII semantics that many terminals expect.<sup id="cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989260_27-5" class="reference"><a href="#cite_note-FOOTNOTELefflerMcKusickKarelsQuarterman1989260-27"><span class="cite-bracket">[</span>27<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-FOOTNOTEBourne1983287_22-1" class="reference"><a href="#cite_note-FOOTNOTEBourne1983287-22"><span class="cite-bracket">[</span>22<span class="cite-bracket">]</span></a></sup></li>
<li>Terminals may be given time to exercise various control codes that would (on a teletypewriter or similar) result in physical movements of the carriage that may take significant (from the computer's point of view) amounts of time, such as backspaces, horizontal tabs, carriage returns, form feeds, and line feeds.<sup id="cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989260_27-6" class="reference"><a href="#cite_note-FOOTNOTELefflerMcKusickKarelsQuarterman1989260-27"><span class="cite-bracket">[</span>27<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-FOOTNOTEBourne1983287&ndash;288_52-0" class="reference"><a href="#cite_note-FOOTNOTEBourne1983287&ndash;288-52"><span class="cite-bracket">[</span>52<span class="cite-bracket">]</span></a></sup></li></ul>
<div class="mw-heading mw-heading2"><h2 id="Notes">Notes</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */
.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}
/* end https://en.wikipedia.org/ */
</style><div class="reflist reflist-columns references-column-width" style="column-width: 35em;">
<ol class="references">
<li id="cite_note-FOOTNOTEChristian198811-1"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTEChristian198811_1-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTEChristian198811_1-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-FOOTNOTEChristian198811_1-2"><sup><i><b>c</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFChristian1988">Christian 1988</a>, p. 11.</span>
</li>
<li id="cite_note-FOOTNOTEBourne19836-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEBourne19836_2-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFBourne1983">Bourne 1983</a>, p. 6.</span>
</li>
<li id="cite_note-FOOTNOTECoffin1991820-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTECoffin1991820_3-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFCoffin1991">Coffin 1991</a>, p. 820.</span>
</li>
<li id="cite_note-FOOTNOTECoffin199123&ndash;24-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTECoffin199123&ndash;24_4-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFCoffin1991">Coffin 1991</a>, p. 23–24.</span>
</li>
<li id="cite_note-FOOTNOTELefflerMcKusickKarelsQuarterman1989259-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989259_5-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFLefflerMcKusickKarelsQuarterman1989">Leffler et al. 1989</a>, p. 259.</span>
</li>
<li id="cite_note-FOOTNOTECoffin199124-6"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTECoffin199124_6-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTECoffin199124_6-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFCoffin1991">Coffin 1991</a>, p. 24.</span>
</li>
<li id="cite_note-FOOTNOTELefflerMcKusickKarelsQuarterman198937&ndash;38-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman198937&ndash;38_7-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFLefflerMcKusickKarelsQuarterman1989">Leffler et al. 1989</a>, p. 37–38.</span>
</li>
<li id="cite_note-FOOTNOTEAfzal2008419-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEAfzal2008419_8-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFAfzal2008">Afzal 2008</a>, p. 419.</span>
</li>
<li id="cite_note-FOOTNOTEFrisch2002770-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEFrisch2002770_9-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFFrisch2002">Frisch 2002</a>, p. 770.</span>
</li>
<li id="cite_note-FOOTNOTECoffin1991115-10"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTECoffin1991115_10-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTECoffin1991115_10-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFCoffin1991">Coffin 1991</a>, p. 115.</span>
</li>
<li id="cite_note-FOOTNOTECoffin1991372-11"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTECoffin1991372_11-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFCoffin1991">Coffin 1991</a>, p. 372.</span>
</li>
<li id="cite_note-FOOTNOTECoffin1991779-12"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTECoffin1991779_12-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFCoffin1991">Coffin 1991</a>, p. 779.</span>
</li>
<li id="cite_note-FOOTNOTECoffin1991751&ndash;752-13"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTECoffin1991751&ndash;752_13-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFCoffin1991">Coffin 1991</a>, p. 751–752.</span>
</li>
<li id="cite_note-FOOTNOTELefflerMcKusickKarelsQuarterman1989265-14"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989265_14-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFLefflerMcKusickKarelsQuarterman1989">Leffler et al. 1989</a>, p. 265.</span>
</li>
<li id="cite_note-FOOTNOTELefflerMcKusickKarelsQuarterman1989103-15"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989103_15-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFLefflerMcKusickKarelsQuarterman1989">Leffler et al. 1989</a>, p. 103.</span>
</li>
<li id="cite_note-FOOTNOTELefflerMcKusickKarelsQuarterman198938-16"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman198938_16-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFLefflerMcKusickKarelsQuarterman1989">Leffler et al. 1989</a>, p. 38.</span>
</li>
<li id="cite_note-FOOTNOTELefflerMcKusickKarelsQuarterman1989260&ndash;261-17"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989260&ndash;261_17-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFLefflerMcKusickKarelsQuarterman1989">Leffler et al. 1989</a>, p. 260–261.</span>
</li>
<li id="cite_note-FOOTNOTELefflerMcKusickKarelsQuarterman1989262-18"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989262_18-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989262_18-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989262_18-2"><sup><i><b>c</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFLefflerMcKusickKarelsQuarterman1989">Leffler et al. 1989</a>, p. 262.</span>
</li>
<li id="cite_note-FOOTNOTEChristian1988395-19"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEChristian1988395_19-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFChristian1988">Christian 1988</a>, p. 395.</span>
</li>
<li id="cite_note-FOOTNOTEBourne19838-20"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEBourne19838_20-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFBourne1983">Bourne 1983</a>, p. 8.</span>
</li>
<li id="cite_note-FOOTNOTEBourne1983130&ndash;131-21"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTEBourne1983130&ndash;131_21-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTEBourne1983130&ndash;131_21-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFBourne1983">Bourne 1983</a>, p. 130–131.</span>
</li>
<li id="cite_note-FOOTNOTEBourne1983287-22"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTEBourne1983287_22-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTEBourne1983287_22-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFBourne1983">Bourne 1983</a>, p. 287.</span>
</li>
<li id="cite_note-FOOTNOTEChristian198826-23"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTEChristian198826_23-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTEChristian198826_23-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFChristian1988">Christian 1988</a>, p. 26.</span>
</li>
<li id="cite_note-FOOTNOTEBourne1983132&ndash;133-24"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEBourne1983132&ndash;133_24-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFBourne1983">Bourne 1983</a>, p. 132–133.</span>
</li>
<li id="cite_note-FOOTNOTELefflerMcKusickKarelsQuarterman1989259&ndash;260-25"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989259&ndash;260_25-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFLefflerMcKusickKarelsQuarterman1989">Leffler et al. 1989</a>, p. 259–260.</span>
</li>
<li id="cite_note-FOOTNOTEBourne1983288-26"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTEBourne1983288_26-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTEBourne1983288_26-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFBourne1983">Bourne 1983</a>, p. 288.</span>
</li>
<li id="cite_note-FOOTNOTELefflerMcKusickKarelsQuarterman1989260-27"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989260_27-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989260_27-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989260_27-2"><sup><i><b>c</b></i></sup></a> <a href="#cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989260_27-3"><sup><i><b>d</b></i></sup></a> <a href="#cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989260_27-4"><sup><i><b>e</b></i></sup></a> <a href="#cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989260_27-5"><sup><i><b>f</b></i></sup></a> <a href="#cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989260_27-6"><sup><i><b>g</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFLefflerMcKusickKarelsQuarterman1989">Leffler et al. 1989</a>, p. 260.</span>
</li>
<li id="cite_note-FOOTNOTEBourne1983132-28"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEBourne1983132_28-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFBourne1983">Bourne 1983</a>, p. 132.</span>
</li>
<li id="cite_note-FOOTNOTEBourne1983133-29"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEBourne1983133_29-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFBourne1983">Bourne 1983</a>, p. 133.</span>
</li>
<li id="cite_note-FOOTNOTEChristian1988393-30"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEChristian1988393_30-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFChristian1988">Christian 1988</a>, p. 393.</span>
</li>
<li id="cite_note-FOOTNOTELefflerMcKusickKarelsQuarterman1989262&ndash;263-31"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTELefflerMcKusickKarelsQuarterman1989262&ndash;263_31-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFLefflerMcKusickKarelsQuarterman1989">Leffler et al. 1989</a>, p. 262–263.</span>
</li>
<li id="cite_note-32"><span class="mw-cite-backlink"><b><a href="#cite_ref-32">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */
.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}
/* end https://en.wikipedia.org/ */
</style><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://minnie.tuhs.org/cgi-bin/utree.pl?file=SysIII/usr/src/man/man4/tty.4">"System III tty(4) man page source"</a><span class="reference-accessdate">. Retrieved <span class="nowrap">October 5,</span> 2012</span>.</cite></span>
</li>
<li id="cite_note-FOOTNOTEZlotnick1991157-33"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTEZlotnick1991157_33-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTEZlotnick1991157_33-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-FOOTNOTEZlotnick1991157_33-2"><sup><i><b>c</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFZlotnick1991">Zlotnick 1991</a>, p. 157.</span>
</li>
<li id="cite_note-FOOTNOTEZlotnick1991163-34"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTEZlotnick1991163_34-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTEZlotnick1991163_34-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-FOOTNOTEZlotnick1991163_34-2"><sup><i><b>c</b></i></sup></a> <a href="#cite_ref-FOOTNOTEZlotnick1991163_34-3"><sup><i><b>d</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFZlotnick1991">Zlotnick 1991</a>, p. 163.</span>
</li>
<li id="cite_note-FOOTNOTEBourne1983130-35"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEBourne1983130_35-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFBourne1983">Bourne 1983</a>, p. 130.</span>
</li>
<li id="cite_note-FOOTNOTEZlotnick1991158-36"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEZlotnick1991158_36-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFZlotnick1991">Zlotnick 1991</a>, p. 158.</span>
</li>
<li id="cite_note-FOOTNOTEZlotnick1991173&ndash;174-37"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEZlotnick1991173&ndash;174_37-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFZlotnick1991">Zlotnick 1991</a>, p. 173–174.</span>
</li>
<li id="cite_note-FOOTNOTEZlotnick1991162-38"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEZlotnick1991162_38-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFZlotnick1991">Zlotnick 1991</a>, p. 162.</span>
</li>
<li id="cite_note-FOOTNOTEZlotnick1991166-39"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTEZlotnick1991166_39-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTEZlotnick1991166_39-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFZlotnick1991">Zlotnick 1991</a>, p. 166.</span>
</li>
<li id="cite_note-FOOTNOTEZlotnick1991162&ndash;163-40"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEZlotnick1991162&ndash;163_40-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFZlotnick1991">Zlotnick 1991</a>, p. 162–163.</span>
</li>
<li id="cite_note-FOOTNOTEZlotnick1991164-41"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEZlotnick1991164_41-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFZlotnick1991">Zlotnick 1991</a>, p. 164.</span>
</li>
<li id="cite_note-FOOTNOTEZlotnick1991165-42"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEZlotnick1991165_42-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFZlotnick1991">Zlotnick 1991</a>, p. 165.</span>
</li>
<li id="cite_note-FOOTNOTEZlotnick1991167-43"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTEZlotnick1991167_43-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTEZlotnick1991167_43-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-FOOTNOTEZlotnick1991167_43-2"><sup><i><b>c</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFZlotnick1991">Zlotnick 1991</a>, p. 167.</span>
</li>
<li id="cite_note-FOOTNOTEZlotnick1991169-44"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTEZlotnick1991169_44-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTEZlotnick1991169_44-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-FOOTNOTEZlotnick1991169_44-2"><sup><i><b>c</b></i></sup></a> <a href="#cite_ref-FOOTNOTEZlotnick1991169_44-3"><sup><i><b>d</b></i></sup></a> <a href="#cite_ref-FOOTNOTEZlotnick1991169_44-4"><sup><i><b>e</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFZlotnick1991">Zlotnick 1991</a>, p. 169.</span>
</li>
<li id="cite_note-FOOTNOTEZlotnick1991172-45"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTEZlotnick1991172_45-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTEZlotnick1991172_45-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-FOOTNOTEZlotnick1991172_45-2"><sup><i><b>c</b></i></sup></a> <a href="#cite_ref-FOOTNOTEZlotnick1991172_45-3"><sup><i><b>d</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFZlotnick1991">Zlotnick 1991</a>, p. 172.</span>
</li>
<li id="cite_note-FOOTNOTEZlotnick1991174-46"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTEZlotnick1991174_46-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTEZlotnick1991174_46-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFZlotnick1991">Zlotnick 1991</a>, p. 174.</span>
</li>
<li id="cite_note-FOOTNOTEZlotnick1991159-47"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTEZlotnick1991159_47-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTEZlotnick1991159_47-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFZlotnick1991">Zlotnick 1991</a>, p. 159.</span>
</li>
<li id="cite_note-FOOTNOTEZlotnick1991160-48"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEZlotnick1991160_48-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFZlotnick1991">Zlotnick 1991</a>, p. 160.</span>
</li>
<li id="cite_note-FOOTNOTEZlotnick1991160&ndash;161-49"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTEZlotnick1991160&ndash;161_49-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTEZlotnick1991160&ndash;161_49-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFZlotnick1991">Zlotnick 1991</a>, p. 160–161.</span>
</li>
<li id="cite_note-FOOTNOTEZlotnick1991161-50"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEZlotnick1991161_50-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFZlotnick1991">Zlotnick 1991</a>, p. 161.</span>
</li>
<li id="cite_note-FOOTNOTEZlotnick1991161&ndash;162-51"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTEZlotnick1991161&ndash;162_51-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTEZlotnick1991161&ndash;162_51-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-FOOTNOTEZlotnick1991161&ndash;162_51-2"><sup><i><b>c</b></i></sup></a> <a href="#cite_ref-FOOTNOTEZlotnick1991161&ndash;162_51-3"><sup><i><b>d</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFZlotnick1991">Zlotnick 1991</a>, p. 161–162.</span>
</li>
<li id="cite_note-FOOTNOTEBourne1983287&ndash;288-52"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEBourne1983287&ndash;288_52-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFBourne1983">Bourne 1983</a>, p. 287–288.</span>
</li>
</ol></div>
<div class="mw-heading mw-heading2"><h2 id="Sources">Sources</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239549316">
/* start https://en.wikipedia.org/ */
.mw-parser-output .refbegin{margin-bottom:0.5em}.mw-parser-output .refbegin-hanging-indents>ul{margin-left:0}.mw-parser-output .refbegin-hanging-indents>ul>li{margin-left:0;padding-left:3.2em;text-indent:-3.2em}.mw-parser-output .refbegin-hanging-indents ul,.mw-parser-output .refbegin-hanging-indents ul li{list-style:none}@media(max-width:720px){.mw-parser-output .refbegin-hanging-indents>ul>li{padding-left:1.6em;text-indent:-1.6em}}.mw-parser-output .refbegin-columns{margin-top:0.3em}.mw-parser-output .refbegin-columns ul{margin-top:0}.mw-parser-output .refbegin-columns li{page-break-inside:avoid;break-inside:avoid-column}@media screen{.mw-parser-output .refbegin{font-size:90%}}
/* end https://en.wikipedia.org/ */
</style><div class="refbegin" style="">
<ul><li><cite id="CITEREFAfzal2008" class="citation book cs1">Afzal, Amir (2008). <i>UNIX unbounded: a beginning approach</i> (5th ed.). Prentice Hall. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-0-13-119449-6</bdi>.</cite></li>
<li><cite id="CITEREFBourne1983" class="citation book cs1"><a href="Stephen_R._Bourne" title="Stephen R. Bourne">Bourne, Stephen R.</a> (1983). <i>The UNIX system</i>. International computer science series. Addison-Wesley. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-0-201-13791-0</bdi>.</cite></li>
<li><cite id="CITEREFChristian1988" class="citation book cs1">Christian, Kaare (1988). <span class="id-lock-registration" title="Free registration required"><a rel="nofollow" class="external text" href="https://archive.org/details/unixoperatingsys0000chri"><i>The UNIX Operating System</i></a></span> (2nd ed.). John Wiley & Sons. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-0-471-84781-6</bdi>.</cite></li>
<li><cite id="CITEREFCoffin1991" class="citation book cs1">Coffin, Stephen (1991). <a rel="nofollow" class="external text" href="https://archive.org/details/unixsystemvrelea00coff"><i>UNIX system V release 4: the complete reference</i></a>. Osborne McGraw-Hill. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-0-07-881653-6</bdi>.</cite></li>
<li><cite id="CITEREFFrisch2002" class="citation book cs1">Frisch, Æleen (2002). <span class="id-lock-registration" title="Free registration required"><a rel="nofollow" class="external text" href="https://archive.org/details/essentialsystema00fris_0"><i>Essential system administration</i></a></span>. A nutshell handbook (3rd ed.). O'Reilly Media, Inc. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-0-596-00343-2</bdi>.</cite></li>
<li><cite id="CITEREFLefflerMcKusickKarelsQuarterman1989" class="citation book cs1">Leffler, Samuel J.; <a href="Marshall_Kirk_McKusick" title="Marshall Kirk McKusick">McKusick, Marshall Kirk</a>; Karels, Michael J.; <a href="John_Quarterman" title="John Quarterman">Quarterman, John S.</a> (1989). "Terminal Handling". <span class="id-lock-registration" title="Free registration required"><a rel="nofollow" class="external text" href="https://archive.org/details/designimplementa0000unse"><i>The Design and implementation of the 4.3BSD UNIX operating system</i></a></span>. Addison-Wesley series in computer science. Addison-Wesley. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-0-201-06196-3</bdi>.</cite></li>
<li><cite id="CITEREFZlotnick1991" class="citation book cs1">Zlotnick, Fred (1991). "Controlling Terminal Devices". <span class="id-lock-registration" title="Free registration required"><a rel="nofollow" class="external text" href="https://archive.org/details/posix1standardpr0000zlot"><i>The POSIX.1 standard: a programmer's guide</i></a></span>. Benjamin/Cummings Pub. Co. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-0-8053-9605-8</bdi>.</cite></li></ul>
</div>
<div class="mw-heading mw-heading2"><h2 id="Further_reading">Further reading</h2></div>
<ul><li><cite class="citation journal cs1"><a rel="nofollow" class="external text" href="http://opengroup.org./onlinepubs/000095399/basedefs/xbd_chap11.html">"11. General Terminal Interface"</a>. <i>The Open Group Base Specifications</i>. 6. <a href="The_Open_Group" title="The Open Group">The Open Group</a>. 2004.</cite></li>
<li><cite id="CITEREFLewine1991" class="citation book cs1">Lewine, Donald A. (1991). "Terminal I/O". <a rel="nofollow" class="external text" href="https://archive.org/details/posixprogrammers00lewi"><i>POSIX programmer's guide: writing portable UNIX programs with the POSIX.1 standard</i></a>. Computer Science Series. O'Reilly Media, Inc. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-0-937175-73-6</bdi>.</cite></li></ul></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-03-08" href="https://en.wikipedia.org/wiki/?title=POSIX_terminal_interface&oldid=1279504141">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>
</body></html>